#ifndef __API_ALG_H
#define __API_ALG_H

///------------------------------------------------------------------------------------------
///AINS3 算法结构体以及相关API声明
typedef struct {
    s16 nt;
    u8  prior_opt_idx;
	u8	music_lev;
	u16 music_lev_hi_range;
	u16 music_lev_hi;
	u16 ns_ps_rate;
	u8	low_fre_lev;
	u16 low_fre_range;
	u16	ns_range_l;
	u16	ns_range_h;
	s32 noise_db;
	s32 noise_db2;
	s32 noise_db3;
	u8 smooth_en;
	//u8  nr_mode;
} ains3_cb_t;

void ains3_init(ains3_cb_t *ains3_cb);
void ains3_process(s16 *data);
void ains3_mic_proc_kick_start(void);
///------------------------------------------------------------------------------------------
///NR_FAR 算法结构体以及相关API声明
void nr_far_process(s16 *data);
void nr_far_init(u16 noise_thr, u16 nr_level);
///------------------------------------------------------------------------------------------
///ROOM_REVERB 算法结构体以及相关API声明
typedef struct
{
	u16 damping_set;        /*高频阻尼，去除高频部分的齿音，擦类的刺耳声*/
	u16 decay_set;          /*衰减率*/
	u16 wet;
	u16 dry;
	u32 samples;
	u8 hpl;                 /*高通滤波器等级0表示关闭,1-10:50hz-500hz,步进50hz*/
}rvb_init_sb;

void room_reverb_process(s16 *sample, u8 idx);
void reverb_buf_init(rvb_init_sb *p, u8 idx);
///------------------------------------------------------------------------------------------
///ECHO 算法结构体以及相关API声明
typedef struct {
	u16 wet;
	u16 dry;
	u16 attenuation;
	s32 delay_length;
	s32 index;
	s32 inter_val0;
	s32 inter_val1;
	s32 inter_val2;
	u8  flag;
	u8  filter_en;
	//s16 delay_rbuf[DELAY_BUF_LENGTH];
} echo_cb_t;

void iir2_filter_init(s32 cutoffFreq_val);
void echo_init_mode(u8 sample_rate, s16 *delay_buf, u16 delay_buf_len, u16 max_delay_len);
void echo_process(s16 *ldata);
void echo_set_param(echo_cb_t *set_param);
void echo_clear_buf(void);
///------------------------------------------------------------------------------------------
///REVERB 算法结构体以及相关API声明
/*plate reverb 初始化结构体*/
typedef struct
{
	u16 predelay_set;       /*预延迟*/
	u16 damping_set;        /*高频阻尼，去除高频部分的齿音，擦类的刺耳声*/
	u16 mix_set;            /*初始化干湿比*/
	u16 ALLPASS_G2_set;     /*衰减扩散，控制尾部密度*/
	u16 decay_set;          /*衰减率*/
	u16 vocals_set;         /*人声部分 值越大 人声越突出  0-65535 */
}prvb_init_sb;

void plate_buf_init(prvb_init_sb *p);
void plate_reverb_process(s16 *ldata, s16 *rdata);
///------------------------------------------------------------------------------------------
///magic 算法结构体以及相关API声明
#define CircleBufo_Len		1536//0.032*Fs

typedef struct {
//Common use
	s32 fre_shift;
	u32 Fs;
	u32 pitch_levels;
	s32 ph1;
	s32 ph2;
	s16 pWtite1;
	s16 pRead1;
	s16 pRead2;
	s16 CircleBuf[CircleBufo_Len];
} pitch_shift2_cb_t;


void pitch_shift2_init(s32 SampleRate, s32 shift, pitch_shift2_cb_t *st);
void pitch_shift2_process(s16 *data, pitch_shift2_cb_t *st);

///------------------------------------------------------------------------------------------
//plc
void plc_soft_init(u8 idx, uint pkt_len);
void plc_soft_process(s16 *int_data, u32 samples, u8 bfi, u8 idx);
void plc_soft_exit(u8 idx);

///------------------------------------------------------------------------------------------
//lc3s
void lc3s_enc_init(u8 sample_rate, u16 samples);
void lc3s_dec_init(u8 sample_rate, u16 samples);
void lc3s_dec(u8 *ibuf, s16 *obuf, uint samples, uint index);
void lc3s_enc(s16 *ibuf, u8 *obuf, uint samples);
uint lc3s_get_frame_size(uint fs_in, u16 samples, u32 bitrate);

void lc3s_stereo_enc_init(u8 sample_rate, u16 samples);
void lc3s_stereo_enc(s16 *ibuf, u8 *obuf, uint samples);
void lc3s_stereo_enc_exit(void);
void lc3s_stereo_dec_init(u8 sample_rate, u16 samples);
void lc3s_stereo_dec(u8 *ibuf, s16 *obuf, uint samples);
void lc3s_stereo_dec_exit(void);


///------------------------------------------------------------------------------------------
///dnn_L1算法结构体以及相关API声明
typedef struct {
	s16 nt;
	u8  nt_post;
	s16 exp_range_H;
	s16 exp_range_L;
	u8  model_select;
	u16 min_value;
	u16 nostation_floor;
	u8  wind_thr;
	u8  wind_en;
	u8  noise_ps_rate;
	u8  prior_opt_idx;
	u8  prior_opt_ada_en;
    u8  param_printf;                           //使能参数打印
    u8  wind_level;
	u16 wind_range;
	u16 low_fre_range;
	u16 low_fre_range0;
	u8  pitch_filter_en;
	u16 mask_floor;
	u8  mask_floor_r;
	u8  music_lev;
	u8  comforN_level;
	u16 gain_expand;
	u8  nn_only;
	u16 nn_only_len;
	//s32 noise_db2;
	//s32 noise_db3;
	u8  smooth_en;
	u16 gain_assign;
	//u16 pitch_filter_range;
} dnn_cb_t;
void dnn_L1_init(dnn_cb_t *dnn_cb);
int dnn_L1_process(s16 *data);
void dnn_L1_mic_proc_kick_start(void);
void dnn_L1_fre_process(s32 *f);
void fft_pre_window(s16 *ptr_in,s16 *ptr_fft);
void fft_next_window(s16 *ptr_out, s16 *ptr_fft, s16 *cirbuf);

#endif // __API_CODEC_H

